﻿@model Contoso_University.Models.Course

@{
    ViewData["Title"] = "新建课程";
}

<h1>新建课程</h1>

<h4>课程信息</h4>
<hr />
<div class="row">
    <div class="col-md-6">
        <form asp-action="Create">
            @if (ViewData["ValidationErrors"] != null)
            {
                <div class="alert alert-danger">
                    <strong>验证错误：</strong> @ViewData["ValidationErrors"]
                </div>
            }
            @if (ViewData["ReceivedData"] != null)
            {
                <div class="alert alert-info">
                    <strong>接收到的数据：</strong> @ViewData["ReceivedData"]
                </div>
            }
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
            <div class="form-group mb-3">
                <label asp-for="CourseID" class="control-label">课程编号</label>
                <input asp-for="CourseID" class="form-control" />
                <span asp-validation-for="CourseID" class="text-danger"></span>
            </div>
            <div class="form-group mb-3">
                <label asp-for="Title" class="control-label">课程名称</label>
                <input asp-for="Title" class="form-control" />
                <span asp-validation-for="Title" class="text-danger"></span>
            </div>
            <div class="form-group mb-3">
                <label asp-for="Credits" class="control-label">学分</label>
                <input asp-for="Credits" class="form-control" />
                <span asp-validation-for="Credits" class="text-danger"></span>
            </div>
            <div class="form-group mb-3">
                <label asp-for="DepartmentID" class="control-label">所属院系</label>
                <select asp-for="DepartmentID" class="form-control" asp-items="ViewBag.DepartmentID"></select>
            </div>
            <div class="form-group">
                <input type="submit" value="创建" class="btn btn-primary" />
                <a asp-action="Index" class="btn btn-secondary">返回列表</a>
            </div>
        </form>
    </div>
</div>

@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
